unit UModule_Register;

interface

uses
  ActnList,
  Classes,
  Dialogs,
  InvokeRegistry,
  Rio,
  SOAPHTTPClient,
  SysUtils;

type
  TModule_Register = class(TDataModule)
    AL: TActionList;
    HTTPRIO1: THTTPRIO;
    PLogin: TAction;
    PLogin_Register: TAction;
    PRegister_Back: TAction;
    PRegister_Save: TAction;
    PResearch_InsertArray: TAction;
    PSetting_Back: TAction;
    procedure PLoginExecute(Sender: TObject);
    procedure HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
    procedure PLogin_RegisterExecute(Sender: TObject);
    procedure PSetting_BackExecute(Sender: TObject);
    procedure PRegister_BackExecute(Sender: TObject);
    procedure PRegister_SaveExecute(Sender: TObject);
    procedure PResearch_InsertArrayExecute(Sender: TObject);
  private
    procedure Assign_LoginInfo;
  public
    procedure Assign_Action;
  end;

var
  Module_Register: TModule_Register;

implementation

uses
  soap_sis_register,
  UMainApplication,
  UUser;
{$R *.dfm}

procedure TModule_Register.Assign_LoginInfo;
begin
try
  with Form_Main do
    begin
    GServer_Host     := IN010301.Text;
    GServer_Database := IN010302.Text;
    GServer_UserName := IN010303.Text;
    GServer_Password := IN010304.Text;
    GUserName        := LE01010101.Text;
    GUserPassword    := LE01010102.Text;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Register.Assign_Action;
begin
try
  with Form_Main do
    begin
    TMB01010101.Action := PLogin;
    TMB01010102.Action := PLogin_Register;
    TMB01030101.Action := PSetting_Back;
    TMB010202.Action   := PRegister_Save;
    TMB010201.Action   := PRegister_Back;
    TMB010401.Action   := PResearch_InsertArray;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Register.HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
var
  LocalStrings: TStringList;
begin
try
  LocalStrings          := TStringList.Create;
  SOAPResponse.Position := 0;
  LocalStrings.LoadFromStream(SOAPResponse);
  // ShowMessage(LocalStrings.Text);
  FreeAndNil(LocalStrings);
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Register.PSetting_BackExecute(Sender: TObject);
begin
try
  with Form_Main, TAB0101 do
    begin
    Show;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Register.PLoginExecute(Sender: TObject);
var
  InfoLogins: TInfologins;
  InfoLogin:  TInfologin;
begin
with Form_Main do
  begin
  try
    with HTTPRIO1 as SERVICE_REGISTERPortType do
      begin
      Assign_LoginInfo;
      InfoLogins := SIS_Login(GServer_Host, GServer_Database, GServer_UserName, GServer_Password, GUserName, GUserPassword);
      if high(InfoLogins) = 0 then
        begin
        InfoLogin             := InfoLogins[0];
        GUser_ID              := InfoLogin.ID;
        GUser_FirstName       := InfoLogin.USER_NAMA_AWAL;
        GUser_MiddleName      := InfoLogin.USER_NAMA_TENGAH;
        GUser_LastName        := InfoLogin.USER_NAMA_AKHIR;
        GUser_Authorization   := InfoLogin.USER_OTORISASI;
        GUser_Email           := InfoLogin.USER_EMAIL;
        GUser_Website         := InfoLogin.USER_WEBSITE;
        GUser_YM              := InfoLogin.USER_YM;
        GUser_Address         := InfoLogin.USER_ALAMAT;
        GUser_City            := InfoLogin.USER_KOTA;
        GUser_Province        := InfoLogin.USER_PROPINSI;
        GUser_Description     := InfoLogin.USER_KETERANGAN;
        LE01050101010101.Text := InfoLogin.User_Name;
        LE01050101010102.Text := InfoLogin.USER_NAMA_AWAL;
        LE01050101010103.Text := InfoLogin.USER_NAMA_TENGAH;
        LE01050101010104.Text := InfoLogin.USER_NAMA_AKHIR;
        LE01050101010105.Text := InfoLogin.USER_OTORISASI;
        LE01050101010106.Text := InfoLogin.USER_EMAIL;
        LE01050101010107.Text := InfoLogin.USER_WEBSITE;
        LE01050101010108.Text := InfoLogin.USER_YM;
        LE01050101010109.Text := InfoLogin.USER_ALAMAT;
        LE01050101010110.Text := InfoLogin.USER_KOTA;
        LE01050101010111.Text := InfoLogin.USER_PROPINSI;
        LE01050101010112.Text := InfoLogin.USER_KETERANGAN;
        with TAB010501010101 do
          begin
          Show;
          end;
        end;
      end;
  except
    on E: Exception do
      begin
      ShowMessage(E.Message);
      end;
  end;
  end;
end;

procedure TModule_Register.PLogin_RegisterExecute(Sender: TObject);
begin
try
  with Form_Main, TAB0102 do
    begin
    Show;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Register.PRegister_BackExecute(Sender: TObject);
begin
try
  with Form_Main, TAB0101 do
    begin
    Show;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Register.PRegister_SaveExecute(Sender: TObject);
var
  InfoServer: TInfoServer;
  InfoLogin:  TInfologin;
begin
try
  Assign_LoginInfo;
  InfoServer := TInfoServer.Create;
  InfoLogin  := TInfologin.Create;
  with Form_Main, HTTPRIO1 as SERVICE_REGISTERPortType do
    begin
    InfoServer.Server_Host     := GServer_Host;
    InfoServer.Server_Database := GServer_Database;
    InfoServer.Server_Username := GServer_UserName;
    InfoServer.Server_Password := GServer_Password;
    InfoLogin.User_Name        := IN0102A01.Text;
    InfoLogin.User_Password    := IN0102A02.Text;
    InfoLogin.USER_NAMA_AWAL   := IN0102B01.Text;
    InfoLogin.USER_NAMA_TENGAH := IN0102B02.Text;
    InfoLogin.USER_NAMA_AKHIR  := IN0102B03.Text;
    InfoLogin.USER_OTORISASI   := IN0102B04.Text;
    InfoLogin.USER_EMAIL       := IN0102B05.Text;
    InfoLogin.USER_WEBSITE     := IN0102B06.Text;
    InfoLogin.USER_YM          := IN0102B07.Text;
    InfoLogin.USER_ALAMAT      := IN0102B08.Text;
    InfoLogin.USER_KOTA        := IN0102B09.Text;
    InfoLogin.USER_PROPINSI    := IN0102B10.Text;
    InfoLogin.USER_KETERANGAN  := IN0102B11.Text;
    SIS_Daftar_Array(InfoServer, InfoLogin);
    PRegister_Back.Execute;
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

procedure TModule_Register.PResearch_InsertArrayExecute(Sender: TObject);
var
  InfoLogin: TInfologin;
begin
try
  with Form_Main, HTTPRIO1 as SERVICE_REGISTERPortType do
    begin
    InfoLogin               := TInfologin.Create;
    InfoLogin.User_Name     := 'ekoindri';
    InfoLogin.User_Password := 'delphi';
    IN010401.Text           := TestInfologin(InfoLogin);
    end;
except
  on E: Exception do
    begin
    ShowMessage(E.Message);
    end;
end;
end;

end.
